
import CorrelationVideoComponent from "./CorrelationVideoComponent"
import $ from 'jquery'
import Fetch from '../modules/fetch'

class InfoComponent extends React.Component {
	
	constructor(props,context){
        super(props,context)
		this.state={
			idNum:this.props.location.pathname.split('/').pop(),
			paixu:{}
		}
        
    }
	
	
	componentWillMount(){
		var that = this
		
		this._getNewsThree(function(news){

			news.forEach(function(item,i){

				if(item.aid==that.state.idNum){

						that.setState({
							paixu:news[i]
						})

					
				}
			})
			
		})
		
	}
	
	 _getNewsThree(cb){
//  	https://api.bilibili.com/x/web-interface/ranking?rid=0&day=3&jsonp=jsonp
    	
    	Fetch.Get("http://localhost:9000/bilili/x/web-interface/ranking", {
			day:3
        }).then(res => {
        	
			return res.json()
		}).then(json => {

			cb(json.data.list)

		})
    }
	
changeTowhat(){
	$(location).attr('href', '#/reg');
}
changeTowhat2(){
	$(location).attr('href', '#/');
}
	
	render() {
		return (
			<div className="infomation">
				
				<div className="header-swipper">		
					<div className="header-top">
			    		<img src="./lib/images/logo.png" alt="" className="header-top__logo" onClick={this.changeTowhat2}/>
			    		<div className="header-top__right">
			    			<img src="./lib/images/tv_icon.gif" alt="" className="userBox_pic"/>
			    			<p onClick={this.changeTowhat}>注册</p>
			    		</div>
			    	</div>
				</div>
			
				<div className="banner_box">
					<img src="//s1.hdslb.com/bfs/static/mult/images/bannerTop.png" />
				</div>
				<div className="personal_infomation">
					<div className="portrait_box">
						<img src="" />
					</div>
					<div className="personal_infomation_list">
						<span className="personal_infomation_name">{this.state.paixu.author}</span>
						<img src="//s1.hdslb.com/bfs/static/mult/images/lv4.png" />
						<span className="personal_infomation_UID">UID:{this.state.paixu.aid}</span>
					</div>
					<div className="personal_fans">
						<span className="attention_num">{this.state.paixu.video_review}</span>关注<span className="fans_num">{this.state.paixu.coins}</span>粉丝
					</div>
					<div className="group_number">
						<span>群号码:655 351496</span>
					</div>
				</div>

				<CorrelationVideoComponent />
			</div>
		)
	}
}

export default InfoComponent